---
title: Load and select a provider-location address
summary: Loads addresses for a provider location and selects the best-available address by requested type.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-08-21
library: SAIF.Business.View.Provider
reference_type: embedded
operation_id: OP-04
trigger: clsProviderLocation.Addresses / ActiveAddresses; clsCaseCost payee-address resolution
---

# Load and select a provider-location address

Loads a location's address rows and applies address-selection logic (active-on-date filtering and a type-based fallback chain) to resolve the best-available address, including cross-location parent/child address resolution.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-04 |
| **Trigger** | `clsProviderLocation.Addresses` / `ActiveAddresses`; `clsCaseCost` payee-address resolution |
| **Inputs** | `IDataPortalInfo`, provider-location ID, optional `AddressTypes` |
| **Outputs** | `clsProviderAddressCollection`, `clsProviderAddress` |
| **Primary components** | `clsProviderAddressCollection.GetProviderAddressCollection`, `clsProviderAddress.GetAddress` |
| **Entry point** | `SAIF.Business.View.Provider/clsProviderAddressCollection.vb:340`; `SAIF.Business.View.Provider/clsProviderAddress.vb:237–290` |

## Steps

1. Collection `BeforeRetrieve` sets `SQLStatement = clsProviderAddress.RETRIEVE_SQL` and binds `:ProviderLocationID` ([SQL-PADR-01](../sql/SQL-PADR-01-provider-addresses.md) against [PROVIDER_ADDRESS](../database-tables.md#provider_address)).
2. `AfterRetrieve` iterates the reader, creating `clsProviderAddress(m_ProviderLocationID)` and calling `Load()` per row. `Fill` applies [BR-PADR-001](../business-rules.md#br-padr-001-addresses-without-expiration-default-to-date-maxvalue): a null `exp_date` is replaced with `Date.MaxValue`.
3. `ActiveAddresses(date)` filters to rows where the date is between `StartDate` and `TerminationDate` ([BR-PADR-002](../business-rules.md#br-padr-002-address-active-on-date-determination)).
4. `CalculatePrimaryAddress(addressType)` applies the fallback chain [BR-PADR-003](../business-rules.md#br-padr-003-primary-address-fallback-chain): Correspondence → Physical; Payment → Physical → Correspondence; Physical → Correspondence.
   - If no address matches: an empty `clsProviderAddress` is returned rather than `Nothing` ([BR-PADR-004](../business-rules.md#br-padr-004-empty-address-returned-when-none-match)).
5. `GetAddress(child, parent, addressType)` applies [BR-PADR-005](../business-rules.md#br-padr-005-parent-address-preferred-with-child-identity-retained): if the parent location has a non-empty address it is cloned and used, tagged `IsParent = True` with the parent's name/ID, but re-stamped with the child's business name and location ID; otherwise the child's own address is returned.
   - Address type resolution uses `GetAddressTypeCode(addressType)`, which enforces [BR-PADR-006](../business-rules.md#br-padr-006-address-type-codes-are-fixed) (fixed codes `COR`/`PAY`/`PHY`; any other value throws).
   - Note: `clsProviderAddress.BeforeRetrieve` only creates `clsUpdateInfo` and issues no data request — the type is never retrieved standalone.**

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([Caller request]) --> S1["BeforeRetrieve binds<br>ProviderLocationID"]
	S1 --> S2[AfterRetrieve: Fill each row<br>null exp_date -> Date.MaxValue]
	S2 --> S3{"Active-date filter<br>requested?"}
	S3 -->|Yes| S4[ActiveAddresses date]
	S3 -->|No| S5[All loaded addresses]
	S4 --> S6[CalculatePrimaryAddress addressType<br>fallback chain]
	S5 --> S6
	S6 --> S7{Match found?}
	S7 -->|Yes| S8(["Best-available address<br>returned"])
	S7 -->|No| S9(["Empty clsProviderAddress<br>returned"])
	S8 --> S10{"Child/parent resolution<br>requested?"}
	S9 --> S10
	S10 -->|Yes| S11[Parent non-empty? Clone + tag IsParent<br>else use child's own address]
	S10 -->|No| EndOk([Address returned])
	S11 --> EndOk
```

## Failure and edge-case behavior

- No address rows loaded for a location: `CalculatePrimaryAddress` returns an empty `clsProviderAddress` object rather than `Nothing` ([BR-PADR-004](../business-rules.md#br-padr-004-empty-address-returned-when-none-match)).
- An unrecognized address type passed to `GetAddressTypeCode` throws `Exception("Invalid Address Type.")` ([BR-PADR-006](../business-rules.md#br-padr-006-address-type-codes-are-fixed)).
- Standalone retrieval of `clsProviderAddress` via the portal is not supported — its `BeforeRetrieve` issues no data request.**

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [SQL catalog](../sql/index.md)
- [Database tables](../database-tables.md)

> **Note:** Statements marked with * were inferred from code structure, naming conventions, or
> contextual evidence where direct confirmation was not available in source artifacts. Statements
> marked with ** could not be confirmed; treat as unknown until verified.

## Sources
- `SAIF.Business.View.Provider/clsProviderAddress.vb`
- `SAIF.Business.View.Provider/clsProviderAddressCollection.vb`
